package name.fowler.refactoring.simplestore.domain;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.ManyToOne;

@Entity
@NamedQuery(name="Rental.findAll", query="SELECT r FROM Rental r") 
public class Rental extends JPAEntity {
	
	@OneToMany(cascade=CascadeType.ALL) 
    private List<Movie> movies;
	
    private int daysRented;

    public Rental() {
    	movies = new LinkedList<Movie>();
    }
    
    public Rental(int daysRented) {
        movies = new LinkedList<Movie>();
        this.daysRented = daysRented;
    }

    public List<Movie> getMovies() {
        return movies;
    }

    public void addMovie(Movie movie) {
        movies.add(movie);
    }

    public int getDaysRented() {
        return daysRented;
    }

}
